package com.sishu.controller;

import com.sishu.pojo.Transactionrecord;
import com.sishu.service.TransactionRecordService;
import com.sishu.utils.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@Slf4j
@RequestMapping("/transaction")
@CrossOrigin(origins = "*")
public class TransactionRecordController {

    @Resource
    private TransactionRecordService transactionRecordService;

    /**
     * @author linyi
     * @date 2025-01-09 14:14:47
     * @description 交易记录 controller  买地的时候moneya要为负数 卖地时moneya要为正数
     */


    @PostMapping
    public Result transactionrecord(@RequestBody Transactionrecord transactionrecord) {
        log.info("transactionrecord = " + transactionrecord);
        return transactionRecordService.transactionrecord(transactionrecord);

    }


    @PostMapping("/teamtransaction")
    public Result transactionteamrecord(@RequestBody Transactionrecord transactionrecord) {
        // return   transactionRecordService.transactionteamrecord(transactionrecord);

        return null;
    }

    @GetMapping("seerecord")
    public Result seerecord(Transactionrecord record) {

        if ("nosearch".equals(record.getType())) {
            return new Result<>(202, "", true);
        }
        return transactionRecordService.selectrecord(record);
    }


}
